package com.yungu.swift.system.sys.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.yungu.swift.base.ResponseData;
import com.yungu.swift.system.sys.dao.SysWayCompanyMapper;
import com.yungu.swift.system.sys.model.dto.SysWayCompanyDto;
import com.yungu.swift.system.sys.service.SysWayCompanyService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;


/**
 * SystemWayCompanyServiceImpl
 **/

@Service
public class SysWayCompanyServiceImpl implements SysWayCompanyService {
    @Autowired
    private SysWayCompanyMapper<SysWayCompanyDto> systemWayCompanyMapper;

    @Override
    public ResponseData<PageList<SysWayCompanyDto>> queryPage(Map<String, Object> params, int pageNum, int pageSize) {
        PageBounds pageBounds = new PageBounds(pageNum, pageSize);
        return ResponseData.buildSuccessResponse(systemWayCompanyMapper.queryPage(params, pageBounds));
    }

    @Override
    public ResponseData<SysWayCompanyDto> findOne(Map<String, Object> params) {
        List<SysWayCompanyDto> list = systemWayCompanyMapper.list(params);
        if (list != null && list.size() > 0) {
            return ResponseData.buildSuccessResponse(list.get(0));
        }
        return ResponseData.buildErrorResponse(ResponseData.ERROR_CODE, "查无符合条件");
    }

    @Override
    public ResponseData<List<SysWayCompanyDto>> listWayByOrganization(String organizationUuid) {
        return ResponseData.buildSuccessResponse(systemWayCompanyMapper.listWayByOrganization(organizationUuid));
    }
}